package com.itheima.controller;

import com.itheima.commons.Result;
import com.itheima.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;

@Controller
//@RequestMapping("/user")
public class UserController {

    @RequestMapping("/login46")
    @ResponseBody
    public Result login(@RequestBody User user, HttpSession session) {
        //判断用户名和密码是否正确
        Result result = new Result();

        if ("酸欠少女さユり".equals(user.getUsername()) && "123".equals(user.getPassword())){
            result.setFlag(true);
            session.setAttribute("username",user.getUsername());
            return result;
        }
        result.setMessage("登录失败了丫，呜呜呜≧ ﹏ ≦");
        return result;
    }


}
